<template>
    <view class="content">
        <div style="height: 30rpx;"></div>
        <div class="card">
            <div style="height: 20rpx;"></div>
            <div class="body">{{ index == 0 ? info.stopTime : index == 1 ? info.createTime : '' }}</div>
            <div style="height: 10rpx;"></div>
            <u-line></u-line>
            <div style="height: 10rpx;"></div>
            <div class="body">
                <div v-if="index!=2">设备名称:{{ info.deviceName }}</div>
                <div v-if="index==2">生产部门:{{ info.deptName }}</div>
                <div style="height: 15rpx;"></div>
                <div>提交人:{{ index == 0 ? info.submitPeople : index == 1 ? info.subPeople : index==2?info.subPerson:'' }}</div>
                <div style="height: 15rpx;"></div>
                <div v-if="index!=2">{{ index == 0 ? '报停原因' : '报修原因' }}:{{ index == 0 ? info.reasonStop : index == 1 ? detailDescription : '' }}</div>
                <div v-if="index==2">生产区域:{{ info.deviceArea }}</div>
                <div style="height: 15rpx;"></div>
                <div v-if="index == 1">紧急程度:{{ info.emerDegree }}</div>
                <div v-if="index == 2">生产设备:{{ info.deviceName }}</div>
                <div v-if="index == 1" style="height: 15rpx;"></div>
                <div v-if="index == 0">报停时长:{{ info.stopDuration }}</div>
                <!-- <div>紧急程度:{{ info.duration }}</div> -->
                <!-- <div>生产区域:{{ info.duration }}</div> -->
                <!-- <div>生产设备:{{ info.duration }}</div> -->
                <div style="height: 15rpx;"></div>
                <div>详情描述:</div>
                <div style="width: 100%;">{{ index == 0 ? info.description : index == 1 ? info.detailDescription : index==2?info.productionDescrip:'' }}</div>
                <div style="height: 20rpx;"></div>
            </div>
        </div>
        <div style="height: 10px;"></div>
        <div v-if="index!=2" class="body" style="display: flex;align-items: center;justify-content: space-between;">
            <div class="img">
                <image :src="base+img1"
                    mode="widthFix" style="width: 150px;height: 150px;"></image>
            </div>
            <div class="img">
                <image :src="base+img2"
                    mode="widthFix" style="width: 150px;height: 150px;"></image>
            </div>
        </div>
    </view>
</template>


<script>
import { stopNoticeDetail, repairNoticeDetail,plantNoticeDetail } from '../api/api';
import request from '../../common/request';
export default {
    data() {
        return {
            info: {

            },
            index: '',
            id: '',
            img1: '',
            img2: '',
            request: request,
            base: ''
        }
    },
    methods: {

    },
    onLoad(options) {
        this.base = this.request.config.baseURL;
        console.log(JSON.parse(options.params));
        let obj = JSON.parse(options.params);
        this.index = obj.index;
        // this.id = obj.id;
        if (obj.index == 0) {
            stopNoticeDetail(obj.id).then(res => {
                console.log(res.data);
                if (res.data.code == 200) {
                    this.info = res.data.data;
                    this.img1 = this.info.devicePhoto.split(',')[0];
                    this.img2 = this.info.devicePhoto.split(',')[1];
                }
            })
        } else if (obj.index == 1) {
            repairNoticeDetail(obj.id).then(res => {
                console.log(res.data);
                if (res.data.code == 200) {
                    this.info = res.data.data;
                    this.img1 = this.info.scenePhoto.split(',')[0];
                    this.img2 = this.info.scenePhoto.split(',')[1];
                }
            })
        }else if(obj.index==2){
            plantNoticeDetail(obj.id).then(res=>{
                console.log(res.data);
                if (res.data.code == 200) {
                    this.info = res.data.data;
                    // this.img1 = this.info.scenePhoto.split(',')[0];
                    // this.img1 = this.info.scenePhoto.split(',')[1];
                }
            })
        }
    },
    onShow() {
        console.log(this.request);
    }
}
</script>

<style lang="scss">
.content {
    background: #E3EDE2;
    overflow-y: scroll;
    height: 100vh;
}

.card {
    width: 90%;
    margin-left: 5%;
    border-radius: 10px;
    background: #B9E2C7;
    font-size: 14px;
}

.body {
    width: 90%;
    margin-left: 5%;
}

.img {
    width: 150px;
    height: 150px;
}
</style>